package cn.iocoder.yudao.module.crm.dal.mysql.course;

import java.util.*;

import cn.iocoder.yudao.framework.common.pojo.PageResult;
import cn.iocoder.yudao.framework.mybatis.core.query.LambdaQueryWrapperX;
import cn.iocoder.yudao.framework.mybatis.core.mapper.BaseMapperX;
import cn.iocoder.yudao.module.crm.dal.dataobject.course.CourseDO;
import org.apache.ibatis.annotations.Mapper;
import cn.iocoder.yudao.module.crm.controller.admin.course.vo.*;

/**
 * 课程 Mapper
 *
 * @author 管理员
 */
@Mapper
public interface CourseMapper extends BaseMapperX<CourseDO> {

    default PageResult<CourseDO> selectPage(CoursePageReqVO reqVO) {
        return selectPage(reqVO, new LambdaQueryWrapperX<CourseDO>()
                .eqIfPresent(CourseDO::getParentId, reqVO.getParentId())
                .likeIfPresent(CourseDO::getName, reqVO.getName())
                .eqIfPresent(CourseDO::getType, reqVO.getType())
                .eqIfPresent(CourseDO::getShowType, reqVO.getShowType())
                .eqIfPresent(CourseDO::getSubjectId, reqVO.getSubjectId())
                .eqIfPresent(CourseDO::getTeacherIds, reqVO.getTeacherIds())
                .eqIfPresent(CourseDO::getClassHour, reqVO.getClassHour())
                .eqIfPresent(CourseDO::getFlag, reqVO.getFlag())
                .eqIfPresent(CourseDO::getStatus, reqVO.getStatus())
                .betweenIfPresent(CourseDO::getCreateTime, reqVO.getCreateTime())
                .in(reqVO.getInCourseIds()!=null&&!reqVO.getInCourseIds().isEmpty(),CourseDO::getId,reqVO.getInCourseIds())
                .notIn(reqVO.getNotInCourseIds()!=null&&!reqVO.getNotInCourseIds().isEmpty(),CourseDO::getId,reqVO.getNotInCourseIds())
                .orderByDesc(CourseDO::getId));
    }


    List<CourseDO> selectAllCourseChapter(List<Long> ids);

}